package info.yaohua;

import info.bean.Ac02;
import info.bean.Ac03;
import info.dao.Ac01Dao;
import info.dao.Ac02Dao;
import info.util.SessionNull;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Xi_gl_Servlet extends HttpServlet
	{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
		{
			// TODO Auto-generated method stub
			HttpSession session=req.getSession(false);
			if(session==null)
				{
					SessionNull.forwordTo(req, resp);
				}
			else
				{
					Ac03 ac03 = (Ac03) session.getAttribute("ac03");
					int x_id = ac03.getX_id();
					Ac02Dao ac02Dao= new Ac02Dao();
					try
						{
							ArrayList list_ac02 = ac02Dao.findAc02ByX_id(x_id);
							int count=list_ac02.size()-1;
							req.setAttribute("count", count);
							req.setAttribute("list_ac02", list_ac02);
							RequestDispatcher view= req.getRequestDispatcher("/glbzr.jsp");
							view.forward(req, resp);
						}
					catch (NamingException | SQLException e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						} 
				}
		}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
		{
			// TODO Auto-generated method stub
			super.doPost(req, resp);
		}
		
	}
